<div class="layui-card-body" style="width: 480px;">
    <form class="layui-form" action="{:url('finadd?project_id='.$project_id)}" method="post">
        <div class="layui-form-item">
            <label class="layui-form-label">财务分类</label>
            <div class="layui-input-inline">
                <select name="project_financial" lay-search>
                    <volist name="project_financial" id="vo" key="k">
                        <option value="{$k}"
                        <notempty name="info.project_financial">
                            <eq name="$k" value="$info.project_financial">selected="selected"</eq>
                        </notempty>
                        > {$vo} </option>
                    </volist>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">财务类型</label>
            <div class="layui-input-inline">
                <select name="financial_type" lay-search>
                    <volist name="financial_type" id="vo" key="k">
                        <option value="{$k}"
                        <notempty name="info.financial_type">
                            <eq name="$k" value="$info.financial_type">selected="selected"</eq>

                            <eq name="$k" value="8"> disabled</eq>
                        </notempty>
                        > {$vo} </option>
                    </volist>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">金额</label>
            <div class="layui-input-inline">
                <input type="text" name="price" value="{$info.price|default=''}" class="layui-input"
                       autocomplete="off" lay-verify="required|number" placeholder="输入发生金额" id="price">
            </div>
        </div>
        <div class="layui-form-mid layui-word-aux" id="price_tip"
             style="color: #FF5722 !important;margin-left: 105px;font-size:16px;margin-top: -15px"></div>

        <div class="layui-form-item">
            <label class="layui-form-label">提醒时间</label>
            <div class="layui-input-inline">
                <input type="text" name="remind_time" value="{$info.remind_time|default=''}" class="layui-input"
                       autocomplete="off" placeholder="如果要提醒请选择日期" id="remind_time" readonly>
            </div>
        </div>
          <div class="layui-form-item ayui-form-text">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-inline">
                <textarea name="info" placeholder="请输入内容" class="layui-textarea" id="info">{$info.info|default=''}</textarea>
            </div>
        </div>
        <input type="hidden" name="project_id" value="{$info.project_id|default=''}">
        <input type="hidden" name="id" value="{$info.id|default=''}">
    </form>
    <blockquote class="layui-elem-quote layui-quote-nm">
        毛利=收入-支付+应收-应付<br>
        毛利会自己计算，添加任意一个记录自动添加毛利记录。<br>
        毛利记录会处在最下面。<br>
    </blockquote>
</div>
<script type="text/javascript">
    layui.use(['form', 'layer', 'formSelects', 'laydate'], function () {
        var form = layui.form
            , formSelects = layui.formSelects
            , laydate = layui.laydate
            , $ = layui.$;
        laydate.render({
            elem: '#remind_time',
            type:'datetime'

        });
        $("#price").on("input", function (e) {
            //获取input输入的值
            console.log(e.delegateTarget.value);
            $('#price_tip').html(DX(e.delegateTarget.value))
        });

        function DX(num) {

            var str1 = '零壹贰叁肆伍陆柒捌玖';  //0-9所对应的汉字
            var str2 = '万仟佰拾亿仟佰拾万仟佰拾元角分'; //数字位所对应的汉字
            var str3;    //从原num值中取出的值
            var str4;    //数字的字符串形式
            var str5 = '';  //人民币大写金额形式
            var i;    //循环变量
            var j;    //num的值乘以100的字符串长度
            var ch1;    //数字的汉语读法
            var ch2;    //数字位的汉字读法
            var nzero = 0;  //用来计算连续的零值是几个
            num = num.replace(",", "");//把逗号替换
            num = Math.abs(num).toFixed(2);  //将num取绝对值并四舍五入取2位小数
            str4 = (num * 100).toFixed(0).toString();  //将num乘100并转换成字符串形式
            j = str4.length;      //找出最高位
            str2 = str2.substr(15 - j);    //取出对应位数的str2的值。如：200.55,j为5所以str2=佰拾元角分

            //循环取出每一位需要转换的值
            for (i = 0; i < j; i++) {
                str3 = str4.substr(i, 1);   //取出需转换的某一位的值
                if (i != (j - 3) && i != (j - 7) && i != (j - 11) && i != (j - 15)) {    //当所取位数不为元、万、亿、万亿上的数字时
                    if (str3 == '0') {
                        ch1 = '';
                        ch2 = '';
                        nzero = nzero + 1;
                    } else {
                        if (str3 != '0' && nzero != 0) {
                            ch1 = '零' + str1.substr(str3 * 1, 1);
                            ch2 = str2.substr(i, 1);
                            nzero = 0;
                        } else {
                            ch1 = str1.substr(str3 * 1, 1);
                            ch2 = str2.substr(i, 1);
                            nzero = 0;
                        }
                    }
                } else { //该位是万亿，亿，万，元位等关键位
                    if (str3 != '0' && nzero != 0) {
                        ch1 = "零" + str1.substr(str3 * 1, 1);
                        ch2 = str2.substr(i, 1);
                        nzero = 0;
                    } else {
                        if (str3 != '0' && nzero == 0) {
                            ch1 = str1.substr(str3 * 1, 1);
                            ch2 = str2.substr(i, 1);
                            nzero = 0;
                        } else {
                            if (str3 == '0' && nzero >= 3) {
                                ch1 = '';
                                ch2 = '';
                                nzero = nzero + 1;
                            } else {
                                if (j >= 11) {
                                    ch1 = '';
                                    nzero = nzero + 1;
                                } else {
                                    ch1 = '';
                                    ch2 = str2.substr(i, 1);
                                    nzero = nzero + 1;
                                }
                            }
                        }
                    }
                }
                if (i == (j - 11) || i == (j - 3)) {  //如果该位是亿位或元位，则必须写上
                    ch2 = str2.substr(i, 1);
                }
                str5 = str5 + ch1 + ch2;

                if (i == j - 1 && str3 == '0') {   //最后一位（分）为0时，加上“整”
                    str5 = str5 + '整';
                }
            }
            if (num == 0) {
                str5 = '零元整';
            }
            return str5;


        };

    });
</script>